home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-07-15 | 4.3 KB | 194 lines | [TEXT/MPS ] |
- {file TrivialLookUp. This is a sample implementation for a trivial look-up system.
- Include a reference to this file and unit in your "uses" clause, compile and link
- to TrivialLookUp.p.o before linking to NetWorkLib.o.
-
- Trivial solutions:
- Register: we do not register at all. Hence we can only be addressed, if a local NetWork
- processor knows us.
- SetSearch: we only default search allowed.
- Active: always claim true.
- Random: return broadcast address
- Next: return local address
- }
-
- { © Copyright 1991 The NetWork Project, StatLab Heidelberg. }
- { © Copyright 1991 G. Sawitzki, Heidelberg. }
-
- unit NetWorkLookup;
-
- interface
-
- { The compile time variables NlServer and NlClient are only included to make
- comparisons with full implementations easier}
- { use "pascal -d NlServer=false" if you don´t want to register your own names }
-
- {$IFC Undefined NlServer}
- {$SETC NlServer:=true}
- {$ENDC}
-
- { use "pascal -d NlClient=false" if you don´t want to look for other programs }
-
- {$IFC Undefined NlClient}
- {$SETC NlClient:=true}
- {$ENDC}
-
- uses Types,
- Errors,
- NetWork;
-
-
- {$IFC UNDEFINED UsingAppletalk}
- type Str32 = String [32];
- {$ENDC}
-
- { ============================================================= }
-
- { name lookup - identication of possible partners }
-
- const
- nlVersion = -31100; { -- no appletalk version 48 or higher, could be removed }
- nlTaskErr = -31103; { -- routines called in wrong order }
- nlNotFound = -31104; { -- used internally }
- nlDupReg = -31105; { -- called NlRegister twice }
- nlNoReg = -31106; { -- called NlDeregister without NlRegister }
- nlAtkOffErr = -31108; { -- appletalk off, cannot use function }
-
-
- nlLocal = 0; { can be used instead of local to denote this machine }
- nlBroadcast = -1; { bradcast address, all of this cable }
-
- function NlNode : longint;
-
- {$IFC NlClient}
-
-
- function NlSetSearch (NlName, NlType, NlZone : Str32) : OSErr;
-
- { start/stop of NL task }
-
- function NlStart : OSErr;
- function NlStop : OSErr;
-
- function NlCount : integer; { or OSErr, if error, NlCount returns the number of partners found. }
- function NLActive (who:longint) : boolean; { is who still on the list ? }
- function NLRandom : longint; { any partner. returns 0 on error.}
- function NLNext(after:longint) : longint; { next partner. NLNext(0) retrurns first. returns 0 on error. }
- function NlTask : OSErr; { call this function periodically }
- function NlGetSleep : longint; { time that may elapse until next call to NlTask }
-
- {$ENDC}
-
- {$IFC NlServer}
-
- { register a server, pass '' to use choosername, only one entity can be registered }
-
- function NlRegister (NlName, NlType : Str32) : OSErr;
- function NlDeregister : OSErr;
-
- {$ENDC}
-
- function NlInit : OSErr;
-
- { this function is obsolete and should no longer be used.
- function NlExit : OSErr;
- }
-
- implementation
-
-
- { ============================================================= }
-
- { name lookup - identication of possible partners }
-
- { this function returns 0 if appletalk is down or driver/appletalk transport not installed }
-
- function NlNode : longint;
- begin
- NlNode := 0;
- end;
-
- {$IFC NlServer}
-
- function NlRegister : OSErr;
- begin
- NlRegister:=noErr;
- end;
-
- function NlDeregister : OSErr;
- begin
- NlDeregister:=noErr;
- end;
- {$ENDC}
-
- {$IFC NlClient}
- function NlSetSearch (NlName, NlType, NlZone : Str32) : OSErr;
- {trivial implementation checks whether parameters correspond to defaults =
- '=:Network Processor@*' }
- begin
- if (NlName<>'=') | (NlType<> 'Network Processor') | (NlZone <>'*')
- then {not default search target}
- NlSetSearch := nlNotFound {error code recycled}
- else
- NlSetSearch := noErr;
- end;
-
-
- function NlStart : OSErr;
- begin
- NlStart := noErr;
- end;
-
- function NlStop : OSErr;
- begin
- NlStop := noErr;
- end;
-
- function NlCount : integer;
- begin
- NlCount := 0;
- end;
-
- function NLActive(who:longint):boolean;
- begin
- NlActive:=true
- end;
-
- function NLRandom:longint;
- begin
- NLRandom:=nlBroadcast;
- end;
-
- function NLNext(after:longint):longint;
- var scr,NrOthers:integer;
- begin
- NLNext:= 0;
- end;
-
- function NlTask : OSErr; { call this function periodically }
- begin
- NlTask:=NoErr;
- end;
-
- function NlGetSleep : longint; { time that may elapse until next call to NlTask }
- begin
- NlGetSleep:=maxlongint;
- end;
-
- {$ENDC}
-
- { ============================================================= }
-
-
- function NlInit : OSErr;
- begin
- NlInit:=NoErr;
- end;
-
- function NlExit : OSErr;
- begin
- NlExit:=NoErr;
- end;
-
-
- end.
-